package com.aaa.hospital.service.impl;

import com.aaa.hospital.mapper.NewsAgreeMapper;
import com.aaa.hospital.pojo.domain.News;
import com.aaa.hospital.pojo.query.NewsAgreeQuery;
import com.aaa.hospital.pojo.vo.NewsVO;
import com.aaa.hospital.result.AjaxResult;
import com.aaa.hospital.service.NewsAgreeService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @program:qy888
 * @description:www
 * @author:LJW
 * @version: 1.0
 * @create:2022-02-23 08:45
 */
@Service
public class NewsAgreeServiceImpl implements NewsAgreeService {

    @Autowired
    private NewsAgreeMapper newsAgreeMapper;


    @Override
    public AjaxResult queryNewsAgree(NewsAgreeQuery newsAgreeQuery) {

        List<News> news =newsAgreeMapper.queryNewsAgree(newsAgreeQuery);

        Long aLong = newsAgreeMapper.queryNewsAgreeTotal(newsAgreeQuery);

        HashMap<Object,Object> objectObjectHashMap = new HashMap<>();

        objectObjectHashMap.put("currentData",news);
        objectObjectHashMap.put("totalCount",aLong);
        return AjaxResult.success(objectObjectHashMap);
    }

    @Override
    public AjaxResult get(Integer id) {
        News n = newsAgreeMapper.seeByID(id);
        return AjaxResult.success(n);
    }

    @Override
    public AjaxResult pass(Integer id) {
        int i = newsAgreeMapper.pass(id);
        if (i<0){
            return AjaxResult.fail();
        }
        return AjaxResult.success();
    }

    @Override
    public AjaxResult refuse(NewsVO newsVO) {
        int i=newsAgreeMapper.refuse(newsVO);
        return AjaxResult.success();
    }
}
